home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume3 / awm2 / part06 < prev    next >
Encoding:
Internet Message Format  |  1989-02-20  |  54.4 KB

  1. Path: uunet!lll-winken!ames!pasteur!ucbvax!decwrl!wyse!mikew
  2. From: mikew@wyse.wyse.com (Mike Wexler)
  3. Newsgroups: comp.sources.x
  4. Subject: v03i022:  Ardent Window Manager, Patchlevel 9, Part06/12
  5. Message-ID: <2072@wyse.wyse.com>
  6. Date: 20 Feb 89 22:24:27 GMT
  7. Organization: Wyse Technology, San Jose
  8. Lines: 1757
  9. Approved: mikew@wyse.com
  10.  
  11. Submitted-by: kmw@ardent (Ken Wallich)  
  12. Posting-number: Volume 3, Issue 22
  13. Archive-name: awm2/part06
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 6 (of 12)."
  22. # Contents:  Neaten.c Titlebar.c globals.c menus/rtlmnu.ext.h
  23. # Wrapped by mikew@wyse on Fri Feb 17 10:50:24 1989
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f 'Neaten.c' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'Neaten.c'\"
  27. else
  28. echo shar: Extracting \"'Neaten.c'\" \(14822 characters\)
  29. sed "s/^X//" >'Neaten.c' <<'END_OF_FILE'
  30. X
  31. X
  32. X
  33. X#ifndef lint
  34. Xstatic char *rcsid_Neaten_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/Neaten.c,v 1.2 89/02/07 21:23:05 jkh Exp $";
  35. X#endif  lint
  36. X
  37. X#include "X11/copyright.h"
  38. X/*
  39. X *
  40. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  41. X *
  42. X * Copyright 1987 by Jordan Hubbard.
  43. X *
  44. X *
  45. X *                         All Rights Reserved
  46. X *
  47. X * Permission to use, copy, modify, and distribute this software and its
  48. X * documentation for any purpose and without fee is hereby granted,
  49. X * provided that the above copyright notice appear in all copies and that
  50. X * both that copyright notice and this permission notice appear in
  51. X * supporting documentation, and that the name of Ardent Computer
  52. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  53. X * pertaining to distribution of the software without specific, written
  54. X * prior permission.
  55. X *
  56. X */
  57. X
  58. X/*
  59. X * MODIFICATION HISTORY
  60. X *
  61. X * 002 -- Jordan Hubbard, Ardent Computer.
  62. X *  Changes to work with awm, specifically reparented windows.
  63. X */
  64. X
  65. X#include "awm.h"
  66. X     
  67. X#ifdef NEATEN
  68. X     
  69. X#include "X11/Xutil.h"
  70. X#include "X11/cursorfont.h"
  71. X#include "neaten.ext.h"
  72. X
  73. Xstatic void GetIconHints();
  74. Xstatic void GetName();
  75. Xextern Boolean IsIcon();
  76. Xextern int neaten_debug_level;
  77. X
  78. X#define TOP_LEVEL (awi->frame ? awi->frame : awi->client)
  79. X
  80. X/*ARGSUSED*/
  81. XBoolean Neaten(window, mask, button, x, y)
  82. XWindow window;                          /* Event window. */
  83. Xint mask;                               /* Button/key mask. */
  84. Xint button;                               /* Button event detail. */
  85. Xint x, y;                               /* Event mouse position. */
  86. X{
  87. X     Window junk_window;
  88. X     Window w;
  89. X     Window icon_window;
  90. X     Window stacktop;
  91. X     Window *children;
  92. X     XWindowAttributes attrs;
  93. X     XSizeHints hints;
  94. X     XWindowChanges  wc;
  95. X     Status rstatus;
  96. X     char name[50];
  97. X     int junk;
  98. X     int root_x, root_y;
  99. X     int root_width, root_height;
  100. X     int icon_x, icon_y;
  101. X     int icon_width, icon_height;
  102. X     int icon_border;
  103. X     int window_x, window_y;
  104. X     int window_width, window_height;
  105. X     int rval;
  106. X     int ix;
  107. X     int iconic;
  108. X     int tiled;
  109. X     int adjustment;
  110. X     int priority;
  111. X     int priority_increment;
  112. X     unsigned int nchildren;
  113. X     unsigned int mapped_children = 0;
  114. X     unsigned int opened_children = 0;
  115. X     unsigned int  wcmask;
  116. X     Placement primary;
  117. X     Placement secondary;
  118. X     Boolean is_iconic;
  119. X     Cursor rtlcursor;
  120. X     XFontStruct *font;
  121. X     GC gc;
  122. X     AwmInfoPtr awi;
  123. X
  124. X     Entry("Neaten")
  125. X
  126. X     font = (XFontStruct *) XLoadQueryFont(dpy, "cursor");
  127. X     gc = DefaultGC(dpy, scr);
  128. X     XSetFont(dpy, gc, font->fid);
  129. X     
  130. X     rtlcursor = XCreateFontCursor(dpy, XC_rtl_logo);
  131. X     
  132. X     XGrabPointer(dpy, RootWindow(dpy, scr), FALSE, (unsigned int) 0,
  133. X          GrabModeAsync, GrabModeAsync,
  134. X          (Window) None, rtlcursor, CurrentTime);
  135. X     
  136. X     if (AbsMinWidth == 0)
  137. X      AbsMinWidth = DEFAULT_ABS_MIN;
  138. X     if (AbsMinHeight == 0)
  139. X      AbsMinHeight = DEFAULT_ABS_MIN;
  140. X     
  141. X     XGetGeometry(dpy, RootWindow(dpy, scr), &junk_window,
  142. X          &root_x, &root_y,
  143. X          &root_width, &root_height,
  144. X          &junk, &junk);
  145. X     
  146. X     Neaten_Initialize(root_width+SEPARATION,
  147. X               root_height+SEPARATION,
  148. X               AbsMinWidth, AbsMinHeight);
  149. X     
  150. X     if (strcmp(PrimaryIconPlacement, "Closest") == 0)
  151. X      primary = Place_Closest;
  152. X     else if (strcmp(PrimaryIconPlacement, "Top") == 0)
  153. X      primary = Place_Top;
  154. X     else if (strcmp(PrimaryIconPlacement, "Bottom") == 0)
  155. X      primary = Place_Bottom;
  156. X     else if (strcmp(PrimaryIconPlacement, "Left") == 0)
  157. X      primary = Place_Left;
  158. X     else if (strcmp(PrimaryIconPlacement, "Right") == 0)
  159. X      primary = Place_Right;
  160. X     else
  161. X      primary = Place_Top;
  162. X     
  163. X     if (strcmp(SecondaryIconPlacement, "Closest") == 0)
  164. X      secondary = Place_Closest;
  165. X     else if (strcmp(SecondaryIconPlacement, "Top") == 0)
  166. X      secondary = Place_Top;
  167. X     else if (strcmp(SecondaryIconPlacement, "Bottom") == 0)
  168. X      secondary = Place_Bottom;
  169. X     else if (strcmp(SecondaryIconPlacement, "Left") == 0)
  170. X      secondary = Place_Left;
  171. X     else if (strcmp(SecondaryIconPlacement, "Right") == 0)
  172. X      secondary = Place_Right;
  173. X     else if (strcmp(SecondaryIconPlacement, "Center") == 0)
  174. X      secondary = Place_Center;
  175. X     else
  176. X      secondary = Place_Left;
  177. X     
  178. X     Neaten_Icon_Placement(primary, secondary);
  179. X     
  180. X     if (XQueryTree(dpy, RootWindow(dpy, scr), &junk_window,
  181. X            &junk_window, &children, &nchildren))
  182. X     {
  183. X      for (ix = 0; ix < nchildren; ix++)
  184. X      {
  185. X           XGetWindowAttributes(dpy, children[ix], &attrs);        
  186. X           
  187. X           if ((attrs.map_state != IsUnmapped) &&
  188. X           (attrs.override_redirect == False) &&
  189. X           (awi = GetAwmInfo(children[ix])))
  190. X           {
  191. X            w = children[ix];
  192. X            if (w != TOP_LEVEL && w != awi->icon)
  193. X             continue;
  194. X            mapped_children++;
  195. X            
  196. X            is_iconic = IsIcon(w, (Window *) NULL);
  197. X            
  198. X            if (is_iconic == TRUE)
  199. X            {
  200. X             window_x = window_y =
  201. X                  window_width = window_height = 0;
  202. X             icon_x = attrs.x;
  203. X             icon_y = attrs.y;
  204. X             icon_width = attrs.width;
  205. X             icon_height = attrs.height;
  206. X             
  207. X             adjustment = SEPARATION;
  208. X             icon_width += adjustment;
  209. X             icon_height += adjustment;
  210. X            }
  211. X            else
  212. X            {
  213. X             window_x = attrs.x;
  214. X             window_y = attrs.y;
  215. X             window_width = attrs.width;
  216. X             window_height = attrs.height;
  217. X             
  218. X             window_x -= attrs.border_width;
  219. X             window_y -= attrs.border_width;
  220. X             
  221. X             adjustment = (2 * attrs.border_width) + SEPARATION;
  222. X             window_width += adjustment;
  223. X             window_height += adjustment;
  224. X             
  225. X             GetIconHints(w, &icon_x, &icon_y,
  226. X                      &icon_width, &icon_height, &icon_border);
  227. X             
  228. X             icon_x -= icon_border;
  229. X             icon_y -= icon_border;
  230. X             icon_width += (2 * icon_border) + SEPARATION;
  231. X             icon_height += (2 * icon_border) + SEPARATION;
  232. X             
  233. X             opened_children++;
  234. X             stacktop = TOP_LEVEL;
  235. X            }
  236. X            
  237. X            GetName(w, name);
  238. X            if(neaten_debug_level)
  239. X            {
  240. X             printf("%s\ticonic = %s\n",
  241. X                name, (is_iconic ? "TRUE" : "FALSE"));
  242. X             printf("\ticon: x = %d y = %d width = %d height = %d\n",
  243. X                icon_x, icon_y, icon_width, icon_height);
  244. X             if (is_iconic != TRUE)
  245. X                  printf("\twindow: x = %d y = %d width = %d height = %d\n",
  246. X                     window_x, window_y, window_width,
  247. X                     window_height);
  248. X            }
  249. X            
  250. X            Neaten_Identify((int) w, is_iconic,
  251. X                    NEATEN_TRUE, NEATEN_FALSE,
  252. X                    window_x, window_y,
  253. X                    window_width, window_height,
  254. X                    NEATEN_TRUE, NEATEN_FALSE,
  255. X                    icon_x, icon_y,
  256. X                    icon_width, icon_height,
  257. X                    (unsigned long) adjustment);
  258. X            
  259. X            rstatus = XGetNormalHints(dpy, w, &hints);
  260. X            if (rstatus != (Status) 0 && is_iconic != TRUE)
  261. X            {
  262. X             if (hints.flags & PMinSize)
  263. X             {
  264. X                  rval = Neaten_Set_Min((int) w,
  265. X                            hints.min_width+adjustment,
  266. X                            hints.min_height+adjustment);
  267. X                  if(neaten_debug_level)
  268. X                   printf("\tmin: width = %d height = %d status = %s\n",
  269. X                      hints.min_width, hints.min_height,
  270. X                      (rval ? "SUCCESS" : "FAILURE"));
  271. X             }
  272. X             if (hints.flags & PMaxSize) 
  273. X             {
  274. X                  rval = Neaten_Set_Max((int) w,
  275. X                            hints.max_width+adjustment,
  276. X                            hints.max_height+adjustment);
  277. X                  if(neaten_debug_level)
  278. X                   printf("\tmax: width = %d height = %d status = %s\n",
  279. X                      hints.max_width, hints.max_height,
  280. X                      (rval ? "SUCCESS" : "FAILURE"));            
  281. X             }
  282. X             if (hints.flags & (USSize | PSize))
  283. X             {
  284. X                  rval = Neaten_Set_Desired((int) w,
  285. X                            hints.width+adjustment,
  286. X                            hints.height+adjustment);
  287. X                  if(neaten_debug_level)
  288. X                   printf("\tdes: width = %d height = %d status = %s\n",
  289. X                      hints.width, hints.height,
  290. X                      (rval ? "SUCCESS" : "FAILURE"));            
  291. X             }
  292. X             
  293. X             /* if no max hints are given, set the max to the
  294. X                max of the desired and current size 
  295. X                */
  296. X             if (!(hints.flags & PMaxSize))
  297. X             {
  298. X                  int desired_width = hints.width+adjustment;
  299. X                  int desired_height = hints.height+adjustment;
  300. X                  
  301. X                  window_width = ((window_width > desired_width)
  302. X                          ? window_width :
  303. X                          desired_width);
  304. X                  window_height = ((window_height > desired_height) 
  305. X                           ? window_height :
  306. X                           desired_height);
  307. X                  rval = Neaten_Set_Max((int) w,
  308. X                            window_width,
  309. X                            window_height);
  310. X                  if(neaten_debug_level)
  311. X                   printf("\tmax: width = %d height = %d status = %s\n",
  312. X                      window_width-adjustment, window_height-adjustment,
  313. X                      (rval ? "SUCCESS" : "FAILURE"));
  314. X             }
  315. X            }
  316. X           }
  317. X      }
  318. X      
  319. X      if (UsePriorities == TRUE)
  320. X      {
  321. X           priority = MIN_PRIORITY;
  322. X           if (opened_children > 1)
  323. X            priority_increment = (MAX_PRIORITY - MIN_PRIORITY) /
  324. X             (opened_children - 1);
  325. X           for (ix = 0; ix < nchildren; ix++)
  326. X           {
  327. X            w = children[ix];
  328. X            awi = GetAwmInfo(w);
  329. X            if (!awi)
  330. X             continue;
  331. X            if (w != TOP_LEVEL && w != awi->icon)
  332. X             continue;
  333. X            is_iconic = IsIcon(w, (Window *) NULL);
  334. X            
  335. X            if (is_iconic != TRUE)
  336. X            {
  337. X             XGetWindowAttributes(dpy, w, &attrs);        
  338. X             if ((attrs.map_state != IsUnmapped) &&
  339. X                 (attrs.override_redirect == False))
  340. X             {
  341. X                  Neaten_Set_Priorities((int) w, priority, priority);
  342. X                  if (neaten_debug_level)
  343. X                  {
  344. X                   GetName(w, name);
  345. X                   printf("%s: priority = %d\n", name, priority);
  346. X                  }
  347. X                  priority += priority_increment;
  348. X             }
  349. X            }
  350. X           }
  351. X      }
  352. X      
  353. X      if (FixTopOfStack == TRUE)
  354. X      {
  355. X           Neaten_Set_Options((int) stacktop, NEATEN_FALSE, NEATEN_TRUE);
  356. X           if (neaten_debug_level)
  357. X           {
  358. X            GetName(stacktop, name);
  359. X            printf("stacktop = %s\n", name);
  360. X           }
  361. X      }
  362. X      
  363. X      if(neaten_debug_level)
  364. X           printf("mapped children = %d\topened_children = %d\n",
  365. X              mapped_children, opened_children);
  366. X      
  367. X      Neaten_Desktop((RetainSize == FALSE), (KeepOpen == FALSE), Fill);
  368. X      
  369. X      for (ix = 0; ix < nchildren; ix++)
  370. X      {
  371. X           w = children[ix];
  372. X           awi = GetAwmInfo(w);
  373. X           if (!awi)
  374. X            continue;
  375. X           if (w != TOP_LEVEL && w != awi->icon)
  376. X            continue;
  377. X           if (Neaten_Get_Geometry((int) w, &iconic, &tiled,
  378. X                       &window_x, &window_y,
  379. X                       &window_width, &window_height,
  380. X                       (unsigned long) &adjustment) == 0)
  381. X            continue;
  382. X           GetName(w, name);
  383. X           if(neaten_debug_level)
  384. X           {
  385. X            printf("%s iconic = %s  tiled = %s\n", name,
  386. X               (iconic ? "TRUE" : "FALSE"),
  387. X               (tiled ? "TRUE" : "FALSE"));
  388. X            printf("   x = %d, y = %d, width = %d, height = %d\n",
  389. X               window_x, window_y, window_width, window_height);
  390. X           }
  391. X           
  392. X           wc.x = window_x;
  393. X           wc.y = window_y;
  394. X           wc.width = window_width;
  395. X           wc.height = window_height;
  396. X           wcmask = CWX | CWY | CWWidth | CWHeight;
  397. X           
  398. X           if (iconic == NEATEN_TRUE)
  399. X           {
  400. X            is_iconic = IsIcon(w, &icon_window);
  401. X            if (is_iconic == TRUE)
  402. X            {
  403. X             wc.width -= adjustment;
  404. X             wc.height -= adjustment;
  405. X             
  406. X             XConfigureWindow(dpy, w, wcmask, &wc);
  407. X             if(tiled != NEATEN_TRUE)
  408. X                  XRaiseWindow(dpy, w);
  409. X            }
  410. X            else
  411. X            {
  412. X             /* have to go to the server to get the info, this
  413. X                could have been avoided if the the variable
  414. X                adjustment was a pointer to a structure that
  415. X                contained the information for the icon and the
  416. X                information for the window.  However, I chose
  417. X                not to mess with all that memory management
  418. X                */
  419. X             GetIconHints(w, &icon_x, &icon_y,
  420. X                      &icon_width, &icon_height, &icon_border);
  421. X             
  422. X             wc.x -= icon_border;
  423. X             wc.y -= icon_border;
  424. X             wc.width -= (2 * icon_border) + SEPARATION;
  425. X             wc.height -= (2 * icon_border) + SEPARATION;
  426. X             
  427. X             XAddToSaveSet(dpy, w);
  428. X             XUnmapWindow(dpy, TOP_LEVEL);
  429. X             XConfigureWindow(icon_window, wcmask, &wc);
  430. X             XMapWindow(dpy, icon_window);
  431. X             if (tiled != NEATEN_TRUE)
  432. X                  XRaiseWindow(dpy, icon_window);
  433. X            }
  434. X           }
  435. X           else
  436. X           {
  437. X            wc.width -= adjustment;
  438. X            wc.height -= adjustment;
  439. X            adjustment -= SEPARATION;
  440. X            wc.x += adjustment/2;
  441. X            wc.y += adjustment/2;
  442. X            /* I think this will be the outer win */
  443. X            ConfigureWindow(w, wcmask, &wc);
  444. X            if(tiled != NEATEN_TRUE)
  445. X             XRaiseWindow(dpy, TOP_LEVEL);
  446. X           }
  447. X      }
  448. X      
  449. X      if (FixTopOfStack == TRUE)
  450. X           XRaiseWindow(dpy, stacktop);
  451. X      
  452. X      XFree(children);
  453. X     }
  454. X     
  455. X     XBell(dpy, VOLUME_PERCENTAGE(Volume));
  456. X     XUngrabPointer(dpy, CurrentTime);
  457. X     Leave(FALSE)
  458. X}
  459. X
  460. Xstatic void
  461. X     GetIconHints(window, x, y, width, height, border)
  462. XWindow window;
  463. Xint *x, *y, *width, *height, *border;
  464. X{
  465. X     Window root;
  466. X     XWMHints *wmhints;
  467. X     XWindowAttributes attrs;
  468. X     int junk;
  469. X     
  470. X     *border = *x = *y = 0;
  471. X     /*
  472. X      * Process window manager hints.
  473. X      */ 
  474. X     if (wmhints = XGetWMHints(dpy, window)) 
  475. X     {
  476. X      if (wmhints->flags&IconWindowHint)
  477. X      {
  478. X           XGetWindowAttributes(dpy, wmhints->icon_window, &attrs);
  479. X           *x = attrs.x;
  480. X           *y = attrs.y;
  481. X           *width = attrs.width;
  482. X           *height = attrs.height;
  483. X           *border = attrs.border_width;
  484. X      }
  485. X      else if (wmhints->flags&IconPixmapHint) 
  486. X      {
  487. X           XGetWindowAttributes(dpy, wmhints->icon_pixmap, &attrs);
  488. X           *width = attrs.width;
  489. X           *height = attrs.height;
  490. X      }
  491. X      else
  492. X      {
  493. X           GetDefaultSize(window, width, height);
  494. X      }
  495. X     }
  496. X     else
  497. X     {
  498. X      GetDefaultSize(window, width, height);
  499. X     }
  500. X     
  501. X     /*
  502. X      * Fix up sizes by padding.
  503. X      */ 
  504. X     if (!wmhints || !(wmhints->flags&(IconPixmapHint|IconWindowHint))) {
  505. X      *width += (HIconPad << 1);
  506. X      *height += (VIconPad << 1);
  507. X     }
  508. X     
  509. X     if (wmhints && (wmhints->flags&IconPositionHint)) {
  510. X      *x = wmhints->icon_x;
  511. X      *y = wmhints->icon_y;
  512. X     }
  513. X}
  514. X
  515. Xstatic void
  516. X     GetName(w, name)
  517. XWindow w;
  518. Xchar *name;
  519. X{
  520. X     Status rstatus;
  521. X     char *s = (char *) NULL;
  522. X     
  523. X     
  524. X     rstatus = XFetchName(dpy, w, &s);
  525. X     
  526. X     if (rstatus != (Status) 0 && s != (char *) NULL)
  527. X     {
  528. X      strcpy(name, s);
  529. X      XFree(s);
  530. X     }
  531. X     else
  532. X     {
  533. X      strcpy(name, "UNKNOWN");
  534. X     }
  535. X}
  536. X
  537. Xvoid NeatenDebug(window, left, top, width, height, adjustment)
  538. Xint window;
  539. Xint left, top;
  540. Xint width, height;
  541. Xunsigned long adjustment;
  542. X{
  543. X     Window w = (Window) window;
  544. X     
  545. X     left += (int) ((float)adjustment/2.0);
  546. X     top += (int) ((float)adjustment/2.0);
  547. X     
  548. X     width -= adjustment;
  549. X     height -= adjustment;
  550. X     
  551. X     XMoveResizeWindow(dpy, w, left, top, width, height);
  552. X     XFlush(dpy);
  553. X}
  554. X#else /* NEATEN not installed */
  555. X/*ARGSUSED*/
  556. XBoolean Neaten(window, mask, button, x, y)
  557. XWindow window;                          /* Event window. */
  558. Xint mask;                               /* Button/key mask. */
  559. Xint button;                               /* Button event detail. */
  560. Xint x, y;                               /* Event mouse position. */
  561. X{
  562. X     fprintf(stderr, "awm: Warning: Neaten package not installed in ");
  563. X     fprintf(stderr, "this version of of awm.\n");
  564. X}
  565. X#endif NEATEN
  566. END_OF_FILE
  567. if test 14822 -ne `wc -c <'Neaten.c'`; then
  568.     echo shar: \"'Neaten.c'\" unpacked with wrong size!
  569. fi
  570. # end of 'Neaten.c'
  571. fi
  572. if test -f 'Titlebar.c' -a "${1}" != "-c" ; then 
  573.   echo shar: Will not clobber existing file \"'Titlebar.c'\"
  574. else
  575. echo shar: Extracting \"'Titlebar.c'\" \(18829 characters\)
  576. sed "s/^X//" >'Titlebar.c' <<'END_OF_FILE'
  577. X
  578. X
  579. X
  580. X#ifndef lint
  581. Xstatic char *rcsid_TitleBar_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/Titlebar.c,v 1.2 89/02/07 21:23:59 jkh Exp $";
  582. X#endif    lint
  583. X
  584. X#include "X11/copyright.h"
  585. X/*
  586. X *
  587. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  588. X *
  589. X * Copyright 1987 by Jordan Hubbard.
  590. X *
  591. X *
  592. X *                         All Rights Reserved
  593. X *
  594. X * Permission to use, copy, modify, and distribute this software and its
  595. X * documentation for any purpose and without fee is hereby granted,
  596. X * provided that the above copyright notice appear in all copies and that
  597. X * both that copyright notice and this permission notice appear in
  598. X * supporting documentation, and that the name of Ardent Computer
  599. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  600. X * pertaining to distribution of the software without specific, written
  601. X * prior permission.
  602. X *
  603. X */
  604. X
  605. X/*
  606. X * MODIFICATION HISTORY
  607. X *
  608. X * 002 -- Jordan Hubbard, U.C. Berkeley.
  609. X Title bar support routines.
  610. X * 1.2 -- Fairly major restructuring to uncouple title bars and
  611. X * border contexts.
  612. X * 1.3 -- Handling of colors revamped significantly to deal with
  613. X * different colormaps.
  614. X */
  615. X
  616. X#include "awm.h"
  617. X#include "X11/Xutil.h"
  618. X#include "X11/cursorfont.h"
  619. X
  620. Xunsigned int TB_wide, TB_high, TBB_wide, TBB_high, BC_wide, BC_high;
  621. Xunsigned int BCB_wide, BCB_high;
  622. X
  623. Xextern XContext AwmContext;
  624. X
  625. X#define BLANK_WIDE    16
  626. X#define BLANK_HIGH    16
  627. Xstatic char blank_bits[] = {
  628. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  629. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  630. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  631. X
  632. Xstatic Boolean Title_res, Frame_res;
  633. X
  634. Xvoid Init_Titles()
  635. X{
  636. X  extern XFontStruct *GetFontRes();
  637. X
  638. X     TFontInfo = GetFontRes("title.font", DEF_TITLE_FONT);
  639. X     TFontBoldInfo = GetFontRes("title.boldFont", (char *) NULL);
  640. X     TBackPixmapData = GetPixmapDataRes("title.pixmap", &TB_wide, &TB_high);
  641. X     TBoldPixmapData = GetPixmapDataRes("title.boldPixmap", &TBB_wide,
  642. X                    &TBB_high);
  643. X     TForeground = GetStringRes("title.foreground", Foreground);
  644. X     TBackground = GetStringRes("title.background", Background);
  645. X     TTextForeground = GetStringRes("title.text.foreground", TForeground);
  646. X     TTextBackground = GetStringRes("title.text.background", TBackground);
  647. X
  648. X     TCursor = GetIntRes("title.cursor", DEF_TITLE_CURSOR);
  649. X
  650. X     TitleHeight = GetIntRes("title.height", 0);
  651. X     TitlePad = GetIntRes("title.pad", DEF_TITLE_PAD);
  652. X     NameOffset = GetIntRes("windowName.offset", 0);
  653. X     titleHeight = TFontInfo->max_bounds.ascent +
  654. X      TFontInfo->max_bounds.descent + (TitlePad * 2);
  655. X     /* we've specified a bold pixmap, but no back pixmap. Use blank. */
  656. X     if (TBoldPixmapData && !TBackPixmapData) {
  657. X      TBackPixmapData = blank_bits;
  658. X      TB_wide = BLANK_WIDE;
  659. X      TB_high = BLANK_HIGH;
  660. X     }
  661. X     if (TFontBoldInfo) {
  662. X      int foo;
  663. X      
  664. X      foo = TFontBoldInfo->max_bounds.ascent +
  665. X           TFontBoldInfo->max_bounds.descent + (TitlePad * 2);
  666. X      if (foo > titleHeight)
  667. X           titleHeight = foo;
  668. X     }
  669. X     if (titleHeight < gadgetHeight)
  670. X      titleHeight = gadgetHeight;
  671. X     if (TitleHeight) /* Specified height overrides derived height */
  672. X      titleHeight = TitleHeight;
  673. X     TitleCursor = XCreateFontCursor(dpy, TCursor);
  674. X     if (!TitleCursor) {
  675. X       char temp[80];
  676. X       sprintf("Init_Titles: Can't get title cursor #%d!\n", TCursor);
  677. X       Error(temp);
  678. X     }
  679. X     /* Gadgets can't exist without titles, so we'll init them here */
  680. X     GadgetPad = GetIntRes("gadget.pad", DEF_GADGET_PAD);
  681. X     GadgetBorder = GetIntRes("gadget.border", DEF_GADGET_BORDER);
  682. X
  683. X     Title_res = TRUE;
  684. X}
  685. X
  686. Xvoid Init_Frames()
  687. X{
  688. X     
  689. X     Entry("Init_Frames")
  690. X
  691. X     BForeground = GetStringRes("borderContext.foreground", Foreground);
  692. X     BBackground = GetStringRes("borderContext.background", Background);
  693. X
  694. X     BCursor = GetIntRes("borderContext.cursor", DEF_BCONTEXT_CURSOR);
  695. X
  696. X     BBackPixmapData = GetPixmapDataRes("borderContext.pixmap", &BC_wide,
  697. X                    &BC_high);
  698. X     BBoldPixmapData = GetPixmapDataRes("borderContext.boldPixmap", &BCB_wide,
  699. X                    &BCB_high);
  700. X     /* we've specified a bold BC pixmap, but no back pixmap. Use blank. */
  701. X     if (BBoldPixmapData && !BBackPixmapData) {
  702. X      BBackPixmapData = blank_bits;
  703. X      BC_wide = BLANK_WIDE;
  704. X      BC_high = BLANK_HIGH;
  705. X     }
  706. X     FrameCursor = XCreateFontCursor(dpy, BCursor);
  707. X     if (!FrameCursor) {
  708. X       char temp[80];
  709. X       sprintf("Init_Frames: Can't get border cursor #%d!\n", BCursor);
  710. X       Error(temp);
  711. X     }
  712. X     Frame_res = TRUE;
  713. X     Leave_void
  714. X}
  715. X
  716. Xchar *GetTitleName(w)
  717. XWindow w;
  718. X{
  719. X     char *cp = 0, *tmp;
  720. X     
  721. X     Entry("GetTitleName")
  722. X      
  723. X     if (!XFetchName(dpy, w, &cp) || !cp)
  724. X      cp = "Untitled Window";
  725. X     tmp = (char *)malloc(strlen(cp) + 3);
  726. X     
  727. X     /*
  728. X      * We add a space on both ends for asthetic effect
  729. X      * (only apparent if we're using inverse video).
  730. X      */
  731. X     tmp[0] = ' ';
  732. X     strcpy(tmp + 1, cp);
  733. X     strcat(tmp, " ");
  734. X     Leave(tmp)
  735. X}
  736. X
  737. X/*
  738. X * Reparent window 'w' into a frame, making the frame the right
  739. X * size to hold any other window related decorations that may be
  740. X * added later. If window 'w' already has a frame, then it resizes
  741. X * it if necessary.
  742. X */
  743. XWindow Reparent(w)
  744. XWindow w;
  745. X{
  746. X     Window foster;
  747. X     XWindowAttributes xwa;
  748. X     XSetWindowAttributes swa;
  749. X     XWMHints *wm_hints;
  750. X     XSizeHints sz_hints;
  751. X     XClassHint class_hints;
  752. X     AwmInfoPtr awi;
  753. X     char *icon_name;
  754. X     int bch, bcv, x, y;
  755. X     unsigned int width, height, bw;
  756. X     int clnt_x, clnt_y;
  757. X     unsigned long valuemask;
  758. X     Boolean decorated = FALSE;
  759. X     Colormap cmap;
  760. X     Pixel bfore, bback;
  761. X
  762. X     Entry("Reparent")
  763. X
  764. X     awi = GetAwmInfo(w);
  765. X     if (!awi) {
  766. X      fprintf(stderr, "Reparent: Window %x isn't registered!\n", w);
  767. X      Leave((Window)NULL)
  768. X     }
  769. X     if (awi->frame && (awi->state & ST_DECORATED))
  770. X      Leave((Window)NULL)
  771. X
  772. X     if (!Frame_res)
  773. X      Init_Frames();
  774. X
  775. X     if (awi->attrs & AT_TITLE && !Title_res)
  776. X      Init_Titles();
  777. X
  778. X     if (!awi->frame)
  779. X      XGetWindowAttributes(dpy, awi->client, &xwa);
  780. X     else
  781. X      XGetWindowAttributes(dpy, awi->frame, &xwa);
  782. X     valuemask = CWEventMask | CWBorderPixel | CWBackPixel | CWColormap;
  783. X     swa.event_mask = (SubstructureRedirectMask | SubstructureNotifyMask);
  784. X     bw = xwa.border_width;
  785. X     x = xwa.x;
  786. X     y = xwa.y;
  787. X     height = xwa.height;
  788. X     width = xwa.width;
  789. X     cmap = xwa.colormap;
  790. X     bfore = GetPixel(BForeground, cmap);
  791. X     bback = GetPixel(BBackground, cmap);
  792. X     clnt_y = clnt_x = 0;
  793. X     if (awi->attrs & AT_BORDER) {
  794. X      XSetWindowAttributes cswa;
  795. X     
  796. X      swa.event_mask |= (ButtonPressMask | ButtonReleaseMask);
  797. X          bcv = BContext + 1;
  798. X      bch = bcv * 2;
  799. X
  800. X      cswa.do_not_propagate_mask =
  801. X           (ButtonPressMask | ButtonReleaseMask);
  802. X      XChangeWindowAttributes(dpy, awi->client, CWDontPropagate, &cswa);
  803. X     }
  804. X     else
  805. X          bch = bcv = 0;
  806. X     if (FrameFocus)
  807. X      swa.event_mask |= (LeaveWindowMask | EnterWindowMask);
  808. X     if (awi->attrs & AT_BORDER) {
  809. X      swa.background_pixel = bfore;
  810. X      swa.border_pixel = bback;
  811. X      decorated = TRUE;
  812. X     }
  813. X     else if (awi->attrs & AT_TITLE) {
  814. X      swa.background_pixel = GetPixel(TBackground, cmap);
  815. X      swa.border_pixel = GetPixel(TForeground, cmap);
  816. X     }
  817. X     else {
  818. X      swa.background_pixel = GetPixel(Background, cmap);
  819. X      swa.border_pixel = GetPixel(Foreground, cmap);
  820. X     }
  821. X     swa.colormap = cmap;
  822. X     if (PushDown == FALSE) {
  823. X      if (awi->attrs & AT_TITLE)
  824. X           y -= (titleHeight + 2);
  825. X      else if (awi->attrs & AT_BORDER)
  826. X           y -= BContext;
  827. X     }
  828. X     /* calculate size for frame */
  829. X     if (awi->attrs & AT_TITLE)
  830. X      height += titleHeight + 2;
  831. X     if (awi->attrs & AT_BORDER) {
  832. X      if (!(awi->attrs & AT_TITLE))
  833. X           height += (bcv * 2);
  834. X      else
  835. X           height += bcv;
  836. X      width += bch;
  837. X     }
  838. X     if (awi->attrs & AT_TITLE)
  839. X      clnt_y = titleHeight + 2;
  840. X     
  841. X     if (awi->attrs & AT_BORDER) {
  842. X      if (!(awi->attrs & AT_TITLE))
  843. X           clnt_y = BContext;
  844. X      clnt_x = BContext;
  845. X     }
  846. X
  847. X     if (!awi->frame) {
  848. X      foster = XCreateWindow(dpy, RootWindow(dpy, scr), x, y, width,
  849. X                 height, (bw ? bw : (unsigned int) 1),
  850. X                 xwa.depth, xwa.class,
  851. X                 xwa.visual, valuemask, &swa);
  852. X      if (!foster)
  853. X           Error("Reparent: Can't create foster parent!");
  854. X
  855. X      if (awi->attrs & AT_BORDER)
  856. X           XDefineCursor(dpy, foster, FrameCursor);
  857. X
  858. X      XAddToSaveSet(dpy, awi->client);
  859. X          XSetWindowBorderWidth(dpy, awi->client,
  860. X                   (unsigned int)((awi->attrs&AT_BORDER) ? 1 : 0));
  861. X      XReparentWindow(dpy, awi->client, foster, clnt_x, clnt_y);
  862. X      XSync(dpy, FALSE);
  863. X
  864. X      if (BBackPixmapData) { /* we have a border context tile */
  865. X           awi->BC_back = GetPixmapFromCache(foster,
  866. X                         BBackPixmapData,
  867. X                         BC_wide, BC_high,
  868. X                         bfore, bback,
  869. X                         xwa.depth);
  870. X           if (!awi->BC_back)
  871. X            Error("Reparent: Can't get pixmap for border context.");
  872. X           else
  873. X            XSetWindowBackgroundPixmap(dpy, foster, awi->BC_back);
  874. X      }
  875. X      if (BBoldPixmapData) { /* we have a bold border context tile */
  876. X           awi->BC_bold = GetPixmapFromCache(foster,
  877. X                         BBoldPixmapData,
  878. X                         BCB_wide, BCB_high,
  879. X                         bfore, bback,
  880. X                         xwa.depth);
  881. X           if (!awi->BC_bold)
  882. X            Error("Reparent: Can't get bold pixmap for border context.");
  883. X      }
  884. X      awi->frame = foster;
  885. X      awi->border_width = bw;
  886. X      awi->name = GetTitleName(awi->client);
  887. X
  888. X      /* Make titlebar "frame" inherit characteristics of victim */
  889. X      XStoreName(dpy, foster, awi->name);
  890. X      if (XGetIconName(dpy, w, &icon_name)) {
  891. X           XSetIconName(dpy, foster, icon_name);
  892. X           XFree(icon_name);
  893. X      }
  894. X      if (wm_hints = XGetWMHints(dpy, awi->client)) {
  895. X           XSetWMHints(dpy, foster, wm_hints);
  896. X           XFree(wm_hints);
  897. X      }
  898. X      XGetNormalHints(dpy, awi->client, &sz_hints);
  899. X      XSetNormalHints(dpy, foster, &sz_hints);
  900. X      XGetZoomHints(dpy, awi->client, &sz_hints);
  901. X      XSetZoomHints(dpy, foster, &sz_hints);
  902. X      class_hints.res_name = class_hints.res_class = (char *)NULL;
  903. X      if (XGetClassHint(dpy, awi->client, &class_hints) == Success) {
  904. X           if (class_hints.res_name || class_hints.res_class)
  905. X            XSetClassHint(dpy, foster, &class_hints);
  906. X      }
  907. X      XSaveContext(dpy, foster, AwmContext, (caddr_t) awi);
  908. X     }
  909. X     else {
  910. X      XMoveResizeWindow(dpy, awi->frame, xwa.x, xwa.y, width, height);
  911. X      XMoveWindow(dpy, awi->client, clnt_x, clnt_y);
  912. X      if (awi->attrs & AT_BORDER)
  913. X           decorated = TRUE;
  914. X      foster = awi->frame;
  915. X     }
  916. X#ifdef RAINBOW
  917. X     if (BorderHilite)
  918. X      SetBorderPixmaps(awi, awi->grayPixmap);
  919. X#endif
  920. X     if (decorated)
  921. X      awi->state |= ST_DECORATED;
  922. X     Leave(foster)
  923. X}
  924. X     
  925. Xvoid AddTitle(w)
  926. XWindow w;
  927. X{
  928. X     int bch;
  929. X     Window title;
  930. X     AwmInfoPtr awi;
  931. X     unsigned long valuemask;
  932. X     XWindowAttributes xwa;
  933. X     XSetWindowAttributes swa;
  934. X     XWindowChanges wc;
  935. X     Pixel tfore, tback;
  936. X
  937. X     Entry("AddTitle")
  938. X
  939. X     awi = GetAwmInfo(w);
  940. X
  941. X     if (!awi) {
  942. X      fprintf(stderr, "AddTitle: Window %x is not registered!\n", w);
  943. X      Leave_void
  944. X     }
  945. X     if (!awi->frame) 
  946. X      Leave_void
  947. X     if (awi->title)
  948. X      Leave_void
  949. X     if (!(awi->attrs & AT_TITLE))
  950. X      Leave_void
  951. X
  952. X     XGetWindowAttributes(dpy, awi->client, &xwa);
  953. X     swa.event_mask = (ExposureMask | ButtonPressMask | ButtonReleaseMask);
  954. X     swa.colormap = xwa.colormap;
  955. X     tfore = GetPixel(TForeground, xwa.colormap);
  956. X     tback = GetPixel(TBackground, xwa.colormap);
  957. X     swa.background_pixel = tback;
  958. X     swa.border_pixel = tfore;
  959. X     valuemask = (CWEventMask | CWColormap | CWBackPixel | CWBorderPixel);
  960. X     if (awi->attrs & AT_BORDER)
  961. X      bch = (BContext * 2) + 2;
  962. X     else
  963. X      bch = 0;
  964. X     title = XCreateWindow(dpy, awi->frame, 0, 0, (xwa.width - 2) + bch,
  965. X               titleHeight,
  966. X               1, xwa.depth, xwa.class, xwa.visual,
  967. X               valuemask, &swa);
  968. X     if (!title)
  969. X      Error("AddTitle: Can't create title bar!");
  970. X     if (TBackPixmapData) {
  971. X      awi->back = GetPixmapFromCache(title, TBackPixmapData,
  972. X                     TB_wide, TB_high,
  973. X                     tfore, tback,
  974. X                     xwa.depth);
  975. X      if (!awi->back)
  976. X           Error("AddTitle: Can't create pixmap for title background");
  977. X      else
  978. X           XSetWindowBackgroundPixmap(dpy, title, awi->back);
  979. X     }
  980. X     if (TBoldPixmapData) {
  981. X      awi->bold = GetPixmapFromCache(title, TBoldPixmapData,
  982. X                     TBB_wide, TBB_high,
  983. X                     tfore, tback,
  984. X                     xwa.depth);
  985. X      if (!awi->bold)
  986. X           Error("AddTitle: Can't create pixmap for bold background");
  987. X     }
  988. X     wc.sibling = awi->client;
  989. X     wc.stack_mode = Above;
  990. X     XConfigureWindow(dpy, title, CWSibling|CWStackMode, &wc);
  991. X     XDefineCursor(dpy, title, TitleCursor);
  992. X     XSelectInput(dpy, title, (ExposureMask | ButtonPressMask |
  993. X               ButtonReleaseMask));
  994. X     XMapWindow(dpy, title);
  995. X     awi->title = title;
  996. X     awi->state |= ST_DECORATED;
  997. X     XSaveContext(dpy, title, AwmContext, (caddr_t) awi);
  998. X}
  999. X
  1000. X/*ARGSUSED*/
  1001. XBoolean FNoDecorate(w, mask, button, x, y)
  1002. XWindow w;
  1003. Xint mask, button, x, y;
  1004. X{
  1005. X     Entry("FNoDecorate")
  1006. X      
  1007. X     if (w == RootWindow(dpy, scr))
  1008. X      Leave(FALSE)
  1009. X     NoDecorate(w, FALSE);
  1010. X     Leave(TRUE)
  1011. X}
  1012. X
  1013. Xvoid NoDecorate(w, destroy)
  1014. XWindow w;
  1015. XBoolean destroy;
  1016. X{
  1017. X     XWindowAttributes xwa;
  1018. X     AwmInfoPtr awi;
  1019. X     extern void DestroyGadgets();
  1020. X
  1021. X     Entry("NoDecorate")
  1022. X
  1023. X     awi = GetAwmInfo(w);
  1024. X     if (!awi || !awi->frame)
  1025. X     Leave_void
  1026. X
  1027. X     if (!(awi->state & ST_DECORATED))
  1028. X     Leave_void
  1029. X     if (awi->gadgets)
  1030. X      DestroyGadgets(w);
  1031. X     if (awi->title) {
  1032. X      XDeleteContext(dpy, awi->title, AwmContext);
  1033. X      if (awi->back)
  1034. X           FreePixmapFromCache(awi->back);
  1035. X      if (awi->bold)
  1036. X           FreePixmapFromCache(awi->bold);
  1037. X      XDestroyWindow(dpy, awi->title);
  1038. X      awi->title = awi->back = awi->bold = (Drawable)NULL;
  1039. X     }
  1040. X     if (destroy) {
  1041. X      XDeleteContext(dpy, awi->frame, AwmContext);
  1042. X      if (awi->BC_back)
  1043. X           FreePixmapFromCache(awi->BC_back);
  1044. X      if (awi->BC_bold)
  1045. X           FreePixmapFromCache(awi->BC_bold);
  1046. X      free(awi->name);
  1047. X      awi->name = (char *)NULL;
  1048. X      XDestroyWindow(dpy, awi->frame);
  1049. X      awi->frame = awi->BC_back = awi->BC_bold = (Drawable)NULL;
  1050. X     }
  1051. X     else {
  1052. X      XGetWindowAttributes(dpy, awi->client, &xwa);
  1053. X      XResizeWindow(dpy, awi->frame, (unsigned int) xwa.width,
  1054. X            (unsigned int) xwa.height);
  1055. X      XMoveWindow(dpy, awi->client, 0, 0);
  1056. X      awi->state ^= ST_DECORATED;
  1057. X     }
  1058. X     XSync(dpy, FALSE);
  1059. X     Leave_void
  1060. X}
  1061. X
  1062. X/*ARGSUSED*/
  1063. XBoolean FDecorate(window, mask, button, x, y)
  1064. XWindow window;
  1065. Xint mask;
  1066. Xint button;
  1067. Xint x, y;
  1068. X{
  1069. X     Window fr;
  1070. X
  1071. X     Entry("FDecorate")
  1072. X
  1073. X     if (window == RootWindow(dpy, scr))
  1074. X      Leave(FALSE)
  1075. X     fr = Decorate(window);
  1076. X     if (fr)
  1077. X      XMapWindow(dpy, fr);
  1078. X     XSync(dpy, FALSE);
  1079. X     Leave(FALSE)
  1080. X}
  1081. X
  1082. XWindow Decorate(w)
  1083. XWindow w;
  1084. X{
  1085. X     Window ret;
  1086. X
  1087. X     Entry("Decorate")
  1088. X
  1089. X     ret = Reparent(w);
  1090. X     if (ret) {
  1091. X      AddTitle(ret);
  1092. X      PutGadgets(ret);
  1093. X     }
  1094. X     Leave(ret)
  1095. X}
  1096. X
  1097. X/*ARGSUSED*/
  1098. Xvoid PaintTitle(w, reversed)
  1099. XWindow w;
  1100. XBoolean reversed;
  1101. X{
  1102. X     int x, y;
  1103. X     XWindowAttributes xwa;
  1104. X     XFontStruct *f_info;
  1105. X     AwmInfoPtr awi;
  1106. X     XGCValues gcv;
  1107. X     Colormap cmap;
  1108. X
  1109. X     Entry("PaintTitle")
  1110. X
  1111. X     if (!(awi = IsTitled(w)))
  1112. X     Leave_void
  1113. X     XGetWindowAttributes(dpy, awi->title, &xwa);
  1114. X     cmap = xwa.colormap;
  1115. X     if (reversed && TFontBoldInfo)
  1116. X      f_info = TFontBoldInfo;
  1117. X     else
  1118. X      f_info = TFontInfo;
  1119. X     gcv.font = f_info->fid;
  1120. X     gcv.foreground = (reversed && !TFontBoldInfo) ?
  1121. X      GetPixel(TTextBackground, cmap) : GetPixel(TTextForeground, cmap);
  1122. X     gcv.background = (reversed && !TFontBoldInfo) ?
  1123. X      GetPixel(TTextForeground, cmap) : GetPixel(TTextBackground, cmap);
  1124. X     XChangeGC(dpy, awi->winGC, (GCFont | GCForeground | GCBackground), &gcv);
  1125. X     XClearWindow(dpy, awi->title);
  1126. X     if (ShowName) {    /* print window names? */
  1127. X      int textlen;
  1128. X
  1129. X      textlen = XTextWidth(f_info, awi->name, strlen(awi->name));
  1130. X
  1131. X      if (!NameOffset)
  1132. X           x = (xwa.width - textlen) / 2;
  1133. X      else {
  1134. X           if (NameOffset < 0)
  1135. X            x = (xwa.width - textlen) + NameOffset;
  1136. X           else
  1137. X            x = NameOffset;
  1138. X           if (x + textlen > xwa.width)
  1139. X            x = (xwa.width - textlen) + 1;
  1140. X      }
  1141. X      y = (xwa.height + f_info->max_bounds.ascent -
  1142. X           f_info->max_bounds.descent) / 2;
  1143. X
  1144. X      XDrawImageString(dpy, awi->title, awi->winGC, x, y, awi->name,
  1145. X               strlen(awi->name));
  1146. X     }
  1147. X     Leave_void
  1148. X}
  1149. X
  1150. XAwmInfoPtr IsTitled(w)
  1151. XWindow w;
  1152. X{
  1153. X     AwmInfoPtr tmp;
  1154. X
  1155. X     Entry("IsTitled")
  1156. X
  1157. X     if (tmp = GetAwmInfo(w))
  1158. X      if (tmp->title)
  1159. X           Leave(tmp)
  1160. X     Leave((AwmInfoPtr)NULL)
  1161. X}
  1162. X
  1163. X/*
  1164. X * These routines deal with a sort of "pixmap cache" that is needed
  1165. X * to minimize the number of pixmaps created by awm. Awm operates on the
  1166. X * assumption that the user may have an arbitrary number of windows at
  1167. X * arbitrary depths. Since awm likes to create resources at the same
  1168. X * depth as the client window, some sort of mechanism is needed to insure
  1169. X * that as few are created as possible.
  1170. X */
  1171. X
  1172. Xstruct _resInfo {
  1173. X     struct _resInfo *next;
  1174. X     Drawable res; 
  1175. X     char *res_data;
  1176. X     Pixel res_fore, res_back;
  1177. X     int res_depth;
  1178. X     int ref_count;
  1179. X} *CacheHead;
  1180. X
  1181. Xstruct _resInfo *allocResNode()
  1182. X{
  1183. X     struct _resInfo *ptr;
  1184. X
  1185. X     Entry("allocResNode")
  1186. X
  1187. X     ptr = (struct _resInfo *)malloc(sizeof(struct _resInfo));
  1188. X     if (!ptr)
  1189. X      fprintf(stderr, "allocResNode: Out of memory!\n");
  1190. X     Leave(ptr)
  1191. X}
  1192. X
  1193. X/*
  1194. X * Look for pixmap in cache and returns it or allocate new pixmap,
  1195. X * store it in cache and return it.
  1196. X */
  1197. XDrawable GetPixmapFromCache(d, data, wide, high, fore, back, depth)
  1198. XDrawable d;
  1199. Xchar *data;
  1200. Xunsigned int wide, high;
  1201. XPixel fore, back;
  1202. Xint depth;
  1203. X{
  1204. X     struct _resInfo *cptr, *iptr;
  1205. X
  1206. X     cptr = iptr = CacheHead;
  1207. X     while (cptr) {
  1208. X      if (cptr->res_depth > depth)
  1209. X           break;
  1210. X      if (cptr->res_depth == depth) {
  1211. X           if (cptr->res_data > data)
  1212. X            break;
  1213. X           else if (cptr->res_data == data) {
  1214. X            if (cptr->res_fore == fore && cptr->res_back == back) {
  1215. X             cptr->ref_count++;
  1216. X             Leave(cptr->res)
  1217. X            }
  1218. X           }
  1219. X      }
  1220. X      iptr = cptr;
  1221. X      cptr = cptr->next;
  1222. X     }
  1223. X     /* fell through, create another resource */
  1224. X     if (!iptr || cptr == CacheHead)    /* need to initialize list */
  1225. X      CacheHead = iptr = allocResNode();
  1226. X     else {
  1227. X      iptr->next = allocResNode();
  1228. X      iptr = iptr->next;
  1229. X     }
  1230. X     iptr->next = cptr;
  1231. X     iptr->res_depth = depth;
  1232. X     iptr->res_data = data;
  1233. X     iptr->res_fore = fore;
  1234. X     iptr->res_back = back;
  1235. X     iptr->res = XCreatePixmapFromBitmapData(dpy, d, data, wide, high,
  1236. X                         fore, back, (unsigned int) depth);
  1237. X     iptr->ref_count = 1;
  1238. X     Leave(iptr->res)
  1239. X}
  1240. X
  1241. X/*
  1242. X * Free pixmap (and associated cache cell) if no longer needed.
  1243. X */
  1244. Xvoid FreePixmapFromCache(pix)
  1245. XPixmap pix;
  1246. X{
  1247. X     struct _resInfo *ptr, *tmp;
  1248. X
  1249. X     ptr = tmp = CacheHead;
  1250. X     while (ptr) {
  1251. X      if (ptr->res == pix)
  1252. X           break;
  1253. X      tmp = ptr;
  1254. X      ptr = ptr->next;
  1255. X     }
  1256. X     if (!ptr)
  1257. X      Leave_void
  1258. X     if (--ptr->ref_count == 0) { /* last ref */
  1259. X      if (ptr == CacheHead)
  1260. X           CacheHead = CacheHead->next;
  1261. X      else
  1262. X           tmp->next = ptr->next;
  1263. X      XFreePixmap(dpy, ptr->res);
  1264. X      free(ptr);
  1265. X     }
  1266. X}
  1267. END_OF_FILE
  1268. if test 18829 -ne `wc -c <'Titlebar.c'`; then
  1269.     echo shar: \"'Titlebar.c'\" unpacked with wrong size!
  1270. fi
  1271. # end of 'Titlebar.c'
  1272. fi
  1273. if test -f 'globals.c' -a "${1}" != "-c" ; then 
  1274.   echo shar: Will not clobber existing file \"'globals.c'\"
  1275. else
  1276. echo shar: Extracting \"'globals.c'\" \(15039 characters\)
  1277. sed "s/^X//" >'globals.c' <<'END_OF_FILE'
  1278. X
  1279. X
  1280. X
  1281. X#ifndef lint
  1282. Xstatic char *rcsid_globals_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/globals.c,v 1.2 89/02/07 21:24:58 jkh Exp $";
  1283. X#endif  lint
  1284. X#include "X11/copyright.h"
  1285. X/*
  1286. X *
  1287. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  1288. X *
  1289. X * Copyright 1987 by Jordan Hubbard.
  1290. X *
  1291. X *
  1292. X *                         All Rights Reserved
  1293. X *
  1294. X * Permission to use, copy, modify, and distribute this software and its
  1295. X * documentation for any purpose and without fee is hereby granted,
  1296. X * provided that the above copyright notice appear in all copies and that
  1297. X * both that copyright notice and this permission notice appear in
  1298. X * supporting documentation, and that the name of Ardent Computer
  1299. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  1300. X * pertaining to distribution of the software without specific, written
  1301. X * prior permission.
  1302. X *
  1303. X */
  1304. X
  1305. X/*
  1306. X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  1307. X *
  1308. X *               All Rights Reserved
  1309. X *
  1310. X * Permission to use, copy, modify, and distribute this software and its
  1311. X * documentation for any purpose and without fee is hereby granted,
  1312. X * provided that the above copyright notice appear in all copies and that
  1313. X * both that copyright notice and this permission notice appear in
  1314. X * supporting documentation, and that the name of Digital Equipment
  1315. X * Corporation not be used in advertising or publicity pertaining to
  1316. X * distribution of the software without specific, written prior permission.
  1317. X *
  1318. X *
  1319. X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  1320. X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  1321. X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  1322. X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1323. X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  1324. X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1325. X * SOFTWARE.
  1326. X */
  1327. X
  1328. X/*
  1329. X * MODIFICATION HISTORY
  1330. X *
  1331. X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
  1332. X * 001 -- R. Kittell, DEC Storage A/D May 19, 1986
  1333. X *  Added global vars for warp options.
  1334. X * 002 -- Loretta Guarino Reid, DEC Ultrix Engineering Group 
  1335. X *  Western Software Lab. April 17, 1987
  1336. X *  Convert to X11
  1337. X * 003 -- Jordan Hubbard, U.C. Berkeley. Misc new vars.
  1338. X * 1.4 -- Vars added for new icon stuff.
  1339. X */
  1340. X#include "awm.h"
  1341. X#include "X11/Xutil.h"
  1342. XWindow Pop;            /* Pop up dimension display window. */
  1343. XWindow Frozen;            /* Contains window id of "gridded" window. */
  1344. XXFontStruct *IFontInfo;        /* Icon text font information. */
  1345. XXFontStruct *PFontInfo;        /* Pop-up text font information. */
  1346. XXFontStruct *TFontInfo;        /* Title text font information. */
  1347. XXFontStruct *TFontBoldInfo;    /* Title text (bold) font information. */
  1348. XXFontStruct *GFontInfo;        /* Gadget box text font */
  1349. XPixmap GrayPixmap;        /* Gray pixmap. */
  1350. XPixmap SolidPixmap;        /* Solid pixmap */
  1351. XPixmap IBackPixmap;        /* Icon window background pixmap. */
  1352. XPixmap IDefPixmap;        /* default icon pixmap for IconLabels */
  1353. XPixel ForeColor;        /* Generic foreground color */
  1354. XPixel BackColor;        /* Generic background color */
  1355. XPixel IBorder;            /* Icon window border color. */
  1356. XPixel PBackground;        /* Pop-up Window background color. */
  1357. XPixel PForeground;        /* Pop-up Window foregrould color */
  1358. XPixel PBorder;            /* Pop-Up Window border color. */
  1359. XPixel IBackground;        /* Icon background (for pixmap) color */
  1360. XPixel IForeground;        /* Icon foreground (for pixmap) color */
  1361. XPixel ITextForeground;        /* Icon text foreground color */
  1362. XPixel ITextBackground;        /* Icon text background color */
  1363. Xchar *Foreground;        /* foreground color (text) */
  1364. Xchar *Background;        /* background color (text) */
  1365. Xchar *WBorder;            /* Window border color */
  1366. Xchar *BBackground;        /* Border context background color */
  1367. Xchar *BForeground;        /* Border context foreground color */
  1368. Xchar *TBackground;        /* Titlebar background color */
  1369. Xchar *TForeground;        /* Titlebar foreground color */
  1370. Xchar *TTextBackground;        /* Titlebar text background color */
  1371. Xchar *TTextForeground;        /* Titlebar text foreground color */
  1372. XCursor ArrowCrossCursor;    /* Arrow cross cursor. */
  1373. XCursor TextCursor;        /* Text cursor used in icon windows. */
  1374. XCursor IconCursor;        /* Icon Cursor. */
  1375. XCursor LeftButtonCursor;    /* Left button main cursor. */
  1376. XCursor MiddleButtonCursor;    /* Middle button main cursor. */
  1377. XCursor RightButtonCursor;    /* Right button main cursor. */
  1378. XCursor TargetCursor;        /* Target (select-a-window) cursor. */
  1379. XCursor TitleCursor;        /* Titlebar cursor */
  1380. XCursor FrameCursor;        /* Border context cursor */
  1381. XCursor GumbyCursor;        /* Used in icons if not type-in */
  1382. Xunsigned int GadgetBorder;    /* Width of gadget borders */
  1383. Xint ScreenWidth;        /* Display screen width. */
  1384. Xint ScreenHeight;        /* Display screen height. */
  1385. Xint IBorderWidth;        /* Icon window border width. */
  1386. Xint TitleHeight;        /* Height of title bar(s) (in pixels) */
  1387. Xint titleHeight;        /* Derived height of title bar(s) in pixels */
  1388. Xint gadgetHeight;        /* Height of highest gadget */
  1389. Xint NameOffset;            /* Offset for window name */
  1390. Xint TitlePad;            /* Padding for titles */
  1391. Xint PWidth;            /* Pop-up window width. */
  1392. Xint PHeight;            /* Pop-up window height. */
  1393. Xunsigned int PBorderWidth;    /* Pop-up window border width. */
  1394. Xint PPadding;            /* Pop-up window padding. */
  1395. Xint Delta;            /* Mouse movement slop. */
  1396. Xint HIconPad;            /* Icon horizontal padding. */
  1397. Xint VIconPad;            /* Icon vertical padding. */
  1398. Xint Pushval;            /* Number of pixels to push window by. */
  1399. Xint BContext;            /* Border context area width (in pixels) */
  1400. Xint RaiseDelay;            /* Number of milliseconds delay before autoraise */
  1401. Xint NumGadgets;            /* Number of gadgets we're using */
  1402. Xint GadgetPad;            /* Amount of padding for gadgets */
  1403. Xint Volume;            /* Audible alarm volume. */
  1404. Xint status;            /* Routine return status. */
  1405. Xunsigned int BCursor;        /* Border context cursor */
  1406. Xunsigned int TCursor;        /* Title context cursor */
  1407. XMenuLink *Menus;        /* Linked list of menus. */
  1408. XGC  IconGC;            /* graphics context for icon */
  1409. XGC  PopGC;            /* graphics context for pop */
  1410. XGC  DrawGC;            /* graphics context for drawing */
  1411. XBinding *Blist;            /* Button/key binding list. */
  1412. X
  1413. XXContext AwmContext;        /* Main context for awm */
  1414. X
  1415. XBoolean Autoselect;        /* Warp mouse to default menu selection? */
  1416. XBoolean Autoraise;        /* Raise window on input focus? */
  1417. XBoolean Borders;        /* Display border context areas? */
  1418. XBoolean ConstrainResize;    /* Don't resize until pointer leaves window */
  1419. XBoolean Freeze;            /* Freeze server during move/resize? */
  1420. XBoolean Grid;            /* Should the m/r box contain a 9 seg. grid. */
  1421. XBoolean ShowName;        /* If True, print window names in titlebars */
  1422. XBoolean Hilite;            /* Should we highlight titles on focus? */
  1423. XBoolean BorderHilite;        /* Should we highlight borders on focus? */
  1424. XBoolean InstallColormap;    /* Should we install colormaps for clients? */
  1425. XBoolean NWindow;        /* Normalize windows? */
  1426. XBoolean NIcon;            /* Normalize icons? */
  1427. XBoolean Push;            /* Relative=TRUE, Absolute=FALSE. */
  1428. XBoolean RootResizeBox;        /* Resize window is placed over sized window? */
  1429. XBoolean ResizeRelative;        /* resizes should be relative to window edge */
  1430. XBoolean Titles;            /* Title bar frob on windows? */
  1431. XBoolean IconLabels;        /* icon labels? */
  1432. XBoolean ILabelTop;        /* icon label on top? */
  1433. XBoolean UseGadgets;        /* Gadget boxes on titles? */
  1434. XBoolean FrameFocus;        /* Treat the frame as part of the window? */
  1435. XBoolean Reverse;        /* Reverse video? */
  1436. XBoolean SaveUnder;        /* Save unders? */
  1437. XBoolean PushDown;        /* Down=TRUE, Up=FALSE */
  1438. XBoolean Wall;            /* restrict to root window boundries? */
  1439. XBoolean WarpOnRaise;        /* Warp to upper right corner on raise. */
  1440. XBoolean WarpOnIconify;          /* Warp to icon center on iconify. */
  1441. XBoolean WarpOnDeIconify;        /* Warp to upper right corner on de-iconify. */
  1442. XBoolean FocusSetByUser;         /* True if f.focus called */
  1443. XBoolean FocusSetByWM;        /* True if awm set the focus */
  1444. XBoolean Zap;            /* Should the the zap effect be used. */
  1445. Xchar PText[7] = INIT_PTEXT;    /* Pop-up window dummy text. */
  1446. Xint PTextSize = sizeof(PText);    /* Pop-up window dummy text size. */
  1447. Xint Lineno = 1;            /* Line count for parser. */
  1448. XBoolean Startup_File_Error = FALSE;/* Startup file error flag. */
  1449. Xchar Startup_File[NAME_LEN] = "";/* Startup file name. */
  1450. Xchar *TBackPixmapData;        /* Bitmap data file title background */
  1451. Xchar *TBoldPixmapData;        /* ditto, except highlighted */
  1452. Xchar *BBackPixmapData;        /* Border context background pixmap data */
  1453. Xchar *BBoldPixmapData;        /* Border context bold pixmap data */
  1454. Xchar *awmPath;            /* Optional pathlist to search for pixmaps */
  1455. Xchar **Argv;            /* Pointer to command line parameters. */
  1456. Xchar **Environ;            /* Pointer to environment. */
  1457. X
  1458. Xchar gray_bits[] = {
  1459. X     0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
  1460. X     0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
  1461. X     0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
  1462. X     0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa
  1463. X};
  1464. X
  1465. Xchar solid_bits[] = {
  1466. X     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1467. X     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1468. X     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1469. X     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
  1470. X};
  1471. X
  1472. Xchar xlogo32_bits[] = {
  1473. X   0xff, 0x00, 0x00, 0xc0, 0xfe, 0x01, 0x00, 0xc0, 0xfc, 0x03, 0x00, 0x60,
  1474. X   0xf8, 0x07, 0x00, 0x30, 0xf8, 0x07, 0x00, 0x18, 0xf0, 0x0f, 0x00, 0x0c,
  1475. X   0xe0, 0x1f, 0x00, 0x06, 0xc0, 0x3f, 0x00, 0x06, 0xc0, 0x3f, 0x00, 0x03,
  1476. X   0x80, 0x7f, 0x80, 0x01, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfe, 0x61, 0x00,
  1477. X   0x00, 0xfe, 0x31, 0x00, 0x00, 0xfc, 0x33, 0x00, 0x00, 0xf8, 0x1b, 0x00,
  1478. X   0x00, 0xf0, 0x0d, 0x00, 0x00, 0xf0, 0x0e, 0x00, 0x00, 0x60, 0x1f, 0x00,
  1479. X   0x00, 0xb0, 0x3f, 0x00, 0x00, 0x98, 0x7f, 0x00, 0x00, 0x98, 0x7f, 0x00,
  1480. X   0x00, 0x0c, 0xff, 0x00, 0x00, 0x06, 0xfe, 0x01, 0x00, 0x03, 0xfc, 0x03,
  1481. X   0x80, 0x01, 0xfc, 0x03, 0xc0, 0x00, 0xf8, 0x07, 0xc0, 0x00, 0xf0, 0x0f,
  1482. X   0x60, 0x00, 0xe0, 0x1f, 0x30, 0x00, 0xe0, 0x1f, 0x18, 0x00, 0xc0, 0x3f,
  1483. X   0x0c, 0x00, 0x80, 0x7f, 0x06, 0x00, 0x00, 0xff};
  1484. X
  1485. Xint scr;
  1486. XDisplay *dpy;
  1487. X
  1488. X#ifdef WMSTATE
  1489. XAtom wm_state_atom;
  1490. X#endif
  1491. X
  1492. X#ifdef NEATEN
  1493. Xint AbsMinWidth;
  1494. Xint AbsMinHeight;
  1495. XBoolean RetainSize;
  1496. XBoolean KeepOpen;
  1497. XBoolean Fill;
  1498. XBoolean UsePriorities;
  1499. XBoolean FixTopOfStack;
  1500. Xchar *PrimaryIconPlacement;
  1501. Xchar *SecondaryIconPlacement;
  1502. X#endif
  1503. X
  1504. X/*
  1505. X * Keyword lookup table for parser.
  1506. X */
  1507. XKeyword KeywordTable[] =
  1508. X{
  1509. X    { "autoselect",    IsBoolean,    &Autoselect, 0 },
  1510. X    { "autoraise",    IsBoolean,    &Autoraise, 0 },
  1511. X    { "freeze",        IsBoolean,    &Freeze, 0 },
  1512. X    { "hilite",        IsBoolean,    &Hilite, 0 },
  1513. X    { "rootResizeBox",    IsBoolean,    &RootResizeBox, 0 },
  1514. X    { "titles",        IsBoolean,    &Titles, 0 },
  1515. X    { "gadgets",    IsBoolean,    &UseGadgets, 0 },
  1516. X    { "grid",        IsBoolean,    &Grid, 0 },
  1517. X    { "showName",    IsBoolean,    &ShowName, 0,},
  1518. X    { "normali",    IsBoolean,    &NIcon, 0 },
  1519. X    { "normalw",    IsBoolean,    &NWindow, 0 },
  1520. X    { "pushRelative",    IsBoolean,    &Push, 0 },
  1521. X    { "reverse",    IsBoolean,    &Reverse, 0 },
  1522. X    { "wall",        IsBoolean,    &Wall, 0 },
  1523. X    { "frameFocus",    IsBoolean,    &FrameFocus, 0 },
  1524. X    { "warpOnIconify",    IsBoolean,    &WarpOnIconify, 0 },
  1525. X    { "warpOnDeIconify",IsBoolean,    &WarpOnDeIconify, 0 },
  1526. X    { "warpOnRaise",    IsBoolean,    &WarpOnRaise, 0 },
  1527. X#ifdef NEATEN
  1528. X    { "retainSize",    IsBoolean,    &RetainSize, 0 },
  1529. X    { "keepOpen",    IsBoolean,    &KeepOpen, 0 },
  1530. X    { "fill",        IsBoolean,    &Fill, 0 },
  1531. X    { "usePriorities",    IsBoolean,    &UsePriorities },
  1532. X    { "fixTopOfStack",    IsBoolean,    &FixTopOfStack },
  1533. X#endif
  1534. X    { "zap",        IsBoolean,    &Zap, 0 },
  1535. X    { "gadget",        IsGadget,    0, 0 },
  1536. X    { "f.beep",        IsImmFunction,    0, Beep },
  1537. X    { "f.circledown",    IsImmFunction,    0, CircleDown },
  1538. X    { "f.circleup",    IsImmFunction,    0, CircleUp },
  1539. X    { "f.continue",    IsImmFunction,    0, Continue },
  1540. X    { "f.decorate",    IsFunction,    0, FDecorate },
  1541. X    { "f.exit",        IsQuitFunction,    0, Quit },
  1542. X    { "f.focus",    IsFunction,    0, Focus },
  1543. X    { "f.unfocus",    IsImmFunction,    0, UnFocus },
  1544. X    { "f.iconify",    IsFunction,    0, Iconify },
  1545. X    { "f.lower",    IsFunction,    0, Lower },
  1546. X    { "f.menu",        IsMenuMap,    0, DoMenu },
  1547. X    { "f.action",    IsAction,    0, DoAction },
  1548. X    { "f.move",        IsDownFunction,    0, Move },
  1549. X    { "f.moveopaque",    IsDownFunction,    0, MoveOpaque },
  1550. X    { "f.newiconify",    IsDownFunction,    0, NewIconify },
  1551. X    { "f.neaten",    IsImmFunction,    0, Neaten },
  1552. X    { "f.pause",    IsImmFunction,    0, Pause },
  1553. X    { "f.pushdown",    IsFunction,    0, ShoveDown },
  1554. X    { "f.pushleft",    IsFunction,    0, ShoveLeft },
  1555. X    { "f.pushright",    IsFunction,    0, ShoveRight },
  1556. X    { "f.pushup",    IsFunction,    0, ShoveUp },
  1557. X    { "f.raise",    IsFunction,    0, Raise },
  1558. X    { "f.redraw",    IsDownFunction,    0, Redraw },
  1559. X    { "f.refresh",    IsImmFunction,    0, Refresh },
  1560. X    { "f.resize",    IsDownFunction,    0, Resize },
  1561. X    { "f.restart",    IsQuitFunction,    0, Restart },
  1562. X    { "f.destroy",      IsDownFunction, 0, DestroyClient },
  1563. X    { "f.nodecorate",   IsFunction,     0, FNoDecorate },
  1564. X    { "f.lock",       IsImmFunction,  0, Lock },
  1565. X    { "menu",        IsMenu,        0, 0 },
  1566. X    { "resetbindings",    IsParser,    0, ResetBindings },
  1567. X    { "resetmenus",    IsParser,    0, ResetMenus },
  1568. X    { "resetgadgets",    IsParser,    0, ResetGadgets },
  1569. X    { NULL,        NULL,        NULL, NULL }
  1570. X};
  1571. X/*
  1572. X * Key expression table for parser.
  1573. X */
  1574. XKeyExpr KeyExprTbl[] = {
  1575. X    { "ctrl", ControlMask },
  1576. X    { "c", ControlMask },
  1577. X    { "lock", LockMask },
  1578. X    { "l", LockMask },
  1579. X    { "meta", Mod1Mask },
  1580. X    { "m", Mod1Mask },
  1581. X    { "shift", ShiftMask },
  1582. X    { "s", ShiftMask },
  1583. X    { "mod1", Mod1Mask },
  1584. X    { "mod2", Mod2Mask },
  1585. X    { "mod3", Mod3Mask },
  1586. X    { "mod4", Mod4Mask },
  1587. X    { "mod5", Mod5Mask },
  1588. X    { NULL, NULL }
  1589. X};
  1590. X/*
  1591. X * Context expression table for parser.
  1592. X */
  1593. XContExpr ContExprTbl[] = {
  1594. X    { "icon", ICON },
  1595. X    { "i", ICON },
  1596. X    { "root", ROOT },
  1597. X    { "r", ROOT },
  1598. X    { "window", WINDOW },
  1599. X    { "w", WINDOW },
  1600. X    { "t", TITLE },
  1601. X    { "title", TITLE },
  1602. X    { "g", GADGET },
  1603. X    { "gadget", GADGET },
  1604. X    { "border", BORDER },
  1605. X    { "b", BORDER },
  1606. X    { NULL, NULL }
  1607. X};
  1608. X
  1609. X/*
  1610. X * Gravity expressions for parser.
  1611. X */
  1612. XGravityExpr GravityExprTbl[] = {
  1613. X    { "noGravity", NoGadgetGravity },
  1614. X    { "nogravity", NoGadgetGravity },
  1615. X    { "NoGravity", NoGadgetGravity },
  1616. X    { "leftGravity", LeftGadgetGravity },
  1617. X    { "leftgravity", LeftGadgetGravity },
  1618. X    { "LeftGravity", LeftGadgetGravity },
  1619. X    { "rightGravity", RightGadgetGravity },
  1620. X    { "rightgravity", RightGadgetGravity },
  1621. X    { "RightGravity", RightGadgetGravity },
  1622. X    { "centerGravity", CenterGadgetGravity },
  1623. X    { "centerGravity", CenterGadgetGravity },
  1624. X    { "CenterGravity", CenterGadgetGravity },
  1625. X    { NULL, NULL}
  1626. X};
  1627. X
  1628. X/*
  1629. X * Button expression table for parser.
  1630. X */
  1631. XButtonModifier ButtModTbl[] = {
  1632. X    { "left", LeftMask },
  1633. X    { "leftbutton", LeftMask },
  1634. X    { "l", LeftMask },
  1635. X    { "middle", MiddleMask },
  1636. X    { "middlebutton", MiddleMask },
  1637. X    { "m", MiddleMask },
  1638. X    { "right", RightMask },
  1639. X    { "rightbutton", RightMask },
  1640. X    { "r", RightMask },
  1641. X    { "move", DeltaMotion },
  1642. X    { "motion", DeltaMotion },
  1643. X    { "delta", DeltaMotion },
  1644. X    { "boogie", DeltaMotion },
  1645. X    { "truckin", DeltaMotion }, /* it's been a silly day... */
  1646. X    { "down", ButtonDown },
  1647. X    { "d", ButtonDown },
  1648. X    { "up", ButtonUp },
  1649. X    { "u", ButtonUp },
  1650. X    { NULL, NULL }
  1651. X};
  1652. END_OF_FILE
  1653. if test 15039 -ne `wc -c <'globals.c'`; then
  1654.     echo shar: \"'globals.c'\" unpacked with wrong size!
  1655. fi
  1656. # end of 'globals.c'
  1657. fi
  1658. if test -f 'menus/rtlmnu.ext.h' -a "${1}" != "-c" ; then 
  1659.   echo shar: Will not clobber existing file \"'menus/rtlmnu.ext.h'\"
  1660. else
  1661. echo shar: Extracting \"'menus/rtlmnu.ext.h'\" \(2298 characters\)
  1662. sed "s/^X//" >'menus/rtlmnu.ext.h' <<'END_OF_FILE'
  1663. X
  1664. X/*
  1665. X#ifndef lint
  1666. Xstatic char sccs_id[] = "@(#)rtlmenu.extern.h    2.1 12/16/87  Siemens Corporate Research and Support, Inc.";
  1667. X#endif
  1668. X*/
  1669. X
  1670. X
  1671. X/* 
  1672. X  RTL Menu Package Version 1.0
  1673. X  by Joe Camaratta and Mike Berman, Siemens RTL, Princeton NJ, 1987
  1674. X
  1675. X  rtlmenu.extern.h: external definitions for rtlmenu user
  1676. X*/
  1677. X
  1678. X/*
  1679. X *
  1680. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  1681. X *
  1682. X * Copyright 1987 by Jordan Hubbard.
  1683. X *
  1684. X *
  1685. X *                         All Rights Reserved
  1686. X *
  1687. X * Permission to use, copy, modify, and distribute this software and its
  1688. X * documentation for any purpose and without fee is hereby granted,
  1689. X * provided that the above copyright notice appear in all copies and that
  1690. X * both that copyright notice and this permission notice appear in
  1691. X * supporting documentation, and that the name of Ardent Computer
  1692. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  1693. X * pertaining to distribution of the software without specific, written
  1694. X * prior permission.
  1695. X *
  1696. X */
  1697. X
  1698. X/*
  1699. XCopyright 1987 by
  1700. X    Siemens Corporate Research and Support, Inc., Princeton, New Jersey
  1701. X
  1702. XPermission to use, copy, modify, and distribute this software
  1703. Xand its documentation for any purpose and without fee is
  1704. Xhereby granted, provided that the above copyright notice
  1705. Xappear in all copies and that both that copyright notice and
  1706. Xthis permission notice appear in supporting documentation, and
  1707. Xthat the name of Siemens not be used in advertising or
  1708. Xpublicity pertaining to distribution of the software without
  1709. Xspecific, written prior permission.  Siemens makes no
  1710. Xrepresentations about the suitability of this software for any
  1711. Xpurpose.  It is provided "as is" without express or implied
  1712. Xwarranty.
  1713. X
  1714. X*/
  1715. X
  1716. Xextern void RTLMenu_Initialize(), RTLMenu_Destroy(),
  1717. X    RTLMenu_Replace_Data_Keyed_String(), RTLMenu_Activate_Entry(),
  1718. X    RTLMenu_Inactivate_Entry(), RTLMenu_Delete_Entries(),
  1719. X    RTLMenu_Delete_String(), RTLMenu_Delete_Data(),
  1720. X    RTLMenu_Enter(), RTLMenu_Generate_Items();
  1721. X    
  1722. Xextern Boolean RTLMenu_Has_Data();
  1723. X
  1724. Xextern RTLMenu RTLMenu_Create(), RTLMenu_Get_Submenu();
  1725. X
  1726. Xextern pointer RTLMenu_Data();
  1727. X
  1728. Xextern RTLMenuItem RTLMenu_Append_String(), RTLMenu_Append_Callback(),
  1729. X    RTLMenu_Append_Call(), RTLMenu_Append_Checkback(),
  1730. X    RTLMenu_Append_Submenu();
  1731. X
  1732. Xextern RTLPoint RTLMenu_Entry_Pos(); 
  1733. END_OF_FILE
  1734. if test 2298 -ne `wc -c <'menus/rtlmnu.ext.h'`; then
  1735.     echo shar: \"'menus/rtlmnu.ext.h'\" unpacked with wrong size!
  1736. fi
  1737. # end of 'menus/rtlmnu.ext.h'
  1738. fi
  1739. echo shar: End of archive 6 \(of 12\).
  1740. cp /dev/null ark6isdone
  1741. MISSING=""
  1742. for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
  1743.     if test ! -f ark${I}isdone ; then
  1744.     MISSING="${MISSING} ${I}"
  1745.     fi
  1746. done
  1747. if test "${MISSING}" = "" ; then
  1748.     echo You have unpacked all 12 archives.
  1749.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1750. else
  1751.     echo You still need to unpack the following archives:
  1752.     echo "        " ${MISSING}
  1753. fi
  1754. ##  End of shell archive.
  1755. exit 0
  1756. -- 
  1757. Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
  1758. Moderator of comp.sources.x
  1759.